﻿namespace RL
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Design;
    using System.Globalization;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;

    [TypeConverter(typeof(DemoClassSorter))]
    public class DemoClass
    {
        private bool mAnInvisibleProperty;
        private bool mBooleanProperty;
        private double mCanPrice;
        private Color mColorProperty;
        private CultureInfo mCultureProperty;
        private Cursor mCursorProperty;
        private DateTime mDateProperty;
        private decimal mDecimalProperty;
        private string mFileProperty;
        private string mFolderProperty;
        private Font mFontProperty;
        private Icon mIconProperty;
        private MultiLineString mLongStringProperty = new MultiLineString();
        private string mPastaProperty;
        private Point mPointProperty;
        private SizeOfCan mSizeOfCanProperty = new SizeOfCan();
        private Size mSizeProperty;
        private string mStringProperty;

        public DemoClass()
        {
            DefaultValueAttribute attribute = (DefaultValueAttribute) TypeDescriptor.GetProperties(this)["StringProperty"].Attributes[typeof(DefaultValueAttribute)];
            this.mStringProperty = attribute.Value.ToString();
            attribute = (DefaultValueAttribute) TypeDescriptor.GetProperties(this)["DecimalProperty"].Attributes[typeof(DefaultValueAttribute)];
            this.mDecimalProperty = Convert.ToDecimal(attribute.Value);
        }

        [Category("Simple Property"), Browsable(false)]
        public bool AnInvisibleProperty
        {
            get
            {
                return this.mAnInvisibleProperty;
            }
            set
            {
                this.mAnInvisibleProperty = value;
            }
        }

        [Category("Simple Property"), Description("Please select a value.")]
        public bool BooleanProperty
        {
            get
            {
                return this.mBooleanProperty;
            }
            set
            {
                this.mBooleanProperty = value;
            }
        }

        [Category("Custom enum"), TypeConverter(typeof(CurrencyConverter))]
        public double CanPrice
        {
            get
            {
                return this.mCanPrice;
            }
            set
            {
                this.mCanPrice = value;
            }
        }

        [Category("System DataType")]
        public Color ColorProperty
        {
            get
            {
                return this.mColorProperty;
            }
            set
            {
                this.mColorProperty = value;
            }
        }

        [Category("System DataType")]
        public CultureInfo CultureProperty
        {
            get
            {
                return this.mCultureProperty;
            }
            set
            {
                this.mCultureProperty = value;
            }
        }

        [Category("System DataType")]
        public Cursor CursorProperty
        {
            get
            {
                return this.mCursorProperty;
            }
            set
            {
                this.mCursorProperty = value;
            }
        }

        [Category("Simple Property")]
        public DateTime DateProperty
        {
            get
            {
                return this.mDateProperty;
            }
            set
            {
                this.mDateProperty = value;
            }
        }

        [DefaultValue("123.45"), Category("Simple Property")]
        public decimal DecimalProperty
        {
            get
            {
                return this.mDecimalProperty;
            }
            set
            {
                this.mDecimalProperty = value;
            }
        }

        [Category("Custom editor"), Description("Click on elipsis to open the editor."), Editor(typeof(MultiLineStringEditor), typeof(UITypeEditor))]
        public MultiLineString Description
        {
            get
            {
                return this.mLongStringProperty;
            }
            set
            {
                this.mLongStringProperty = value;
            }
        }

        [Editor(typeof(FileNameEditor), typeof(UITypeEditor)), Category("Browser")]
        public string FileProperty
        {
            get
            {
                return this.mFileProperty;
            }
            set
            {
                this.mFileProperty = value;
            }
        }

        [Editor(typeof(FolderNameEditor), typeof(UITypeEditor)), Category("Browser")]
        public string FolderProperty
        {
            get
            {
                return this.mFolderProperty;
            }
            set
            {
                this.mFolderProperty = value;
            }
        }

        [Category("System DataType")]
        public Font FontProperty
        {
            get
            {
                return this.mFontProperty;
            }
            set
            {
                this.mFontProperty = value;
            }
        }

        [Category("System DataType")]
        public Icon IconProperty
        {
            get
            {
                return this.mIconProperty;
            }
            set
            {
                this.mIconProperty = value;
            }
        }

        [TypeConverter(typeof(PastaList)), Category("Custom enum"), Description("Select your prefered favor of pasta from the list.")]
        public string PastaProperty
        {
            get
            {
                return this.mPastaProperty;
            }
            set
            {
                this.mPastaProperty = value;
            }
        }

        [Category("System DataType")]
        public Point PointProperty
        {
            get
            {
                return this.mPointProperty;
            }
            set
            {
                this.mPointProperty = value;
            }
        }

        [Category("Custom enum"), Description("Specify the size of the can.")]
        public SizeOfCan SizeOfCanProperty
        {
            get
            {
                return this.mSizeOfCanProperty;
            }
            set
            {
                this.mSizeOfCanProperty = value;
            }
        }

        [Category("System DataType")]
        public Size SizeProperty
        {
            get
            {
                return this.mSizeProperty;
            }
            set
            {
                this.mSizeProperty = value;
            }
        }

        [DefaultValue("\x00c9ric Moreau"), Category("Simple Property")]
        public string StringProperty
        {
            get
            {
                return this.mStringProperty;
            }
            set
            {
                this.mStringProperty = value;
            }
        }
    }
}

